
use  Data/Individual_withsolar.dta, replace
	
	
	

	gen peersolar = cum - (has_solar/1000)

  
  
  
	label variable peersolar "Peer Solar Rooftops (000s)"
	label variable has_solar "Adopted Solar"
  
  
	label variable median_income_interp "Median Income (AUD 000s)"
	label variable median_mortgage_interp "Median Mortgage Payment (AUD 000s)"
	label variable median_rent_interp "Median Rental Payment (AUD 000s)" 
	label variable PBachelor_interp "Proportion Bachelor's Degree"
	label variable PRented_interp "Proportion Rental Properties"
	label variable median_rooms_interp "Median House Size"
	label variable PFullTime_interp "Proportion Employed Full Time"
	label variable median_age_interp "Median Age"
  
	xtset postcode
  
  
  
  

	local length = 3
		 
	forval t = 0(1)`length' {
		gen event_after`t' =  SHCP_end ==`t' |  PFIT_starttime==`t' | PFIT_endtime==`t' | ///
		 SRES1_end ==`t' | SRES2_end==`t' | SRES_TFIT_endtime==`t' | FFIT_endtime==`t'
		 
		 
		 gen event_before`t' =  SHCP_end ==-`t'  | PFIT_starttime==-`t' | PFIT_endtime==-`t' | ///
		 SRES1_end ==-`t' | SRES2_end==-`t' | SRES_TFIT_endtime==-`t' | FFIT_endtime==-`t'
		
		gen event_after_new`t' = event_after`t'*peersolar
		gen event_before_new`t' = event_before`t'*peersolar
		
		
		
		gen event_after_high`t' = event_after`t'*roofrelativeIV
		gen event_before_high`t' = event_before`t'*roofrelativeIV
		
		gen has_after_new`t' = event_after`t'*has_solar
		gen has_before_new`t' = event_before`t'*has_solar
		
		
		
		drop event_after`t'
		drop event_before`t'
		
		
		
		}
			
		
	* reference time 
	drop    event_after_new0 // event_before_high1 event_before_new1


	label variable event_before_new3  "Event period -3"
	label variable event_before_new2  "Event period -2"
	label variable event_before_new1  "Event period -1"
	label variable event_before_new0  "Event period "
	label variable event_after_new1   "Event period +1"
	label variable event_after_new2   "Event period +2"
	label variable event_after_new3   "Event period +3"



	label variable has_before_new3  "Event period -3"
	label variable has_before_new2  "Event period -2"
	label variable has_before_new1  "Event period -1"
	label variable has_before_new0  "Event period "
	label variable has_after_new1   "Event period +1"
	label variable has_after_new2   "Event period +2"
	label variable has_after_new3   "Event period +3"

	
	


  
  
  
  **** WITH SOLAR HOUSEHOLDS
  
  	xi: xtivreg2 green_p (event_before_new3 event_before_new2 event_before_new1 event_before_new0 ///
	event_after_new1  event_after_new2 event_after_new3  =   ///
	event_after_high3 event_after_high2 event_after_high1 event_before_high0 ///
	event_before_high1  event_before_high2 event_before_high3) i.quarter if roofrelativeIV<. , fe cluster(postcode) 

	
	
	quietly summ green_plan if e(sample)
    local meandepvar=round(`r(mean)',.001)

	
	
outreg2 using Analysis/IV_event_withsolarpeer, bdec(3) label ctitle("IV")  addstat(CDW F-test, e(widstat)) ///
keep(event*) addtext(Postcode FE, Yes, Year-Quarter FE, Yes, Mean dep var, 0`meandepvar') ///
tex(fragment pretty) nonotes replace
 
 
 
 
 
  	xi: xtivreg2 green_p (event_before_new3 event_before_new2 event_before_new1 event_before_new0 ///
	event_after_new1  event_after_new2 event_after_new3  =   ///
	event_after_high3 event_after_high2 event_after_high1 event_before_high0 ///
	event_before_high1  event_before_high2 event_before_high3) has_solar i.quarter if roofrelativeIV<. , fe cluster(postcode) 

	
	
	quietly summ green_plan if e(sample)
    local meandepvar=round(`r(mean)',.001)

	
	
outreg2 using Analysis/IV_event_withsolarpeer, bdec(3) label ctitle("IV")  addstat(CDW F-test, e(widstat)) ///
keep(event* has_solar) addtext(Postcode FE, Yes, Year-Quarter FE, Yes, Mean dep var, 0`meandepvar') ///
tex(fragment pretty) nonotes append
	

	
	
	
  	xi: xtivreg2 green_p (event_before_new3 event_before_new2 event_before_new1 event_before_new0 ///
	event_after_new1  event_after_new2 event_after_new3  =   ///
	event_after_high3 event_after_high2 event_after_high1 event_before_high0 ///
	event_before_high1  event_before_high2 event_before_high3 ) has_before_new3 has_before_new2 has_before_new1 has_before_new0 ///
	has_after_new1  has_after_new2 has_after_new3 i.quarter if roofrelativeIV<. , fe cluster(postcode) 

	
	
	quietly summ green_plan if e(sample)
    local meandepvar=round(`r(mean)',.001)

	
	
outreg2 using Analysis/IV_event_withsolarpeer, bdec(3) label ctitle("IV")  addstat(CDW F-test, e(widstat)) ///
keep(event* has*) addtext(Postcode FE, Yes, Year-Quarter FE, Yes, Mean dep var, 0`meandepvar') ///
tex(fragment pretty) nonotes append
	
	
	
